import { ref } from 'vue';
import { defineStore } from 'pinia';
import StorageService from '@/services/storage';
import type { User } from '@/types/api/user';
import { LOCALSTORAGE_USERINFO } from '@/config';

export const useUserStore = defineStore('user', () => {
  const user = ref(StorageService.getLocal(LOCALSTORAGE_USERINFO, {}));

  function setUser(value: User | null) {
    user.value = value;
  }
  return { user, setUser };
});
